#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

#这种模式是直接在构建镜像的内部编译发布dotnet项目。
#注意下容器内输出端口是9291
#如果你想先手动dotnet build成可执行的二进制文件，然后再构建镜像，请看.Api层下的dockerfile。


FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
WORKDIR /src
COPY ["MyWebAPI.Api/MyWebAPI.Api.csproj", "MyWebAPI.Api/"]
COPY ["MyWebAPI.Extensions/MyWebAPI.Extensions.csproj", "MyWebAPI.Extensions/"]
COPY ["MyWebAPI.Tasks/MyWebAPI.Tasks.csproj", "MyWebAPI.Tasks/"]
COPY ["MyWebAPI.IServices/MyWebAPI.IServices.csproj", "MyWebAPI.IServices/"]
COPY ["MyWebAPI.Model/MyWebAPI.Model.csproj", "MyWebAPI.Model/"]
COPY ["MyWebAPI.Common/MyWebAPI.Common.csproj", "MyWebAPI.Common/"]
COPY ["MyWebAPI.Services/MyWebAPI.Services.csproj", "MyWebAPI.Services/"]
COPY ["MyWebAPI.Repository/MyWebAPI.Repository.csproj", "MyWebAPI.Repository/"]
COPY ["MyWebAPI.EventBus/MyWebAPI.EventBus.csproj", "MyWebAPI.EventBus/"]
RUN dotnet restore "MyWebAPI.Api/MyWebAPI.Api.csproj"
COPY . .
WORKDIR "/src/MyWebAPI.Api"
RUN dotnet build "MyWebAPI.Api.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "MyWebAPI.Api.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
EXPOSE 9291 
ENTRYPOINT ["dotnet", "MyWebAPI.Api.dll"]